﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Windows.Controls.Ribbon;

namespace ChoDiaOc_HK_WPF.Views {
    /// <summary>
    /// Interaction logic for ManHinhQuanLy.xaml
    /// </summary>
    public partial class ManHinhQuanLy : RibbonWindow {

        private QuanLy.QuanLyDangNhap quanLyDangNhapControl = null;

        public QuanLy.QuanLyDangNhap QuanLyDangNhapControl {
            get {
                if (quanLyDangNhapControl == null) {
                    quanLyDangNhapControl = new QuanLy.QuanLyDangNhap();
                } return quanLyDangNhapControl;
            }
        }

        private QuanLy.QuanLyGia quanLyGiaControl = null;

        public QuanLy.QuanLyGia QuanLyGiaControl {
            get {
                if (quanLyGiaControl == null) {
                    quanLyGiaControl = new QuanLy.QuanLyGia();
                } return quanLyGiaControl;
            }
        }

        private QuanLy.QuanLyDiaOc quanLyDiaOcControl = null;

        public QuanLy.QuanLyDiaOc QuanLyDiaOcControl {
            get {
                if (quanLyDiaOcControl == null) {
                    quanLyDiaOcControl = new QuanLy.QuanLyDiaOc();
                } return quanLyDiaOcControl;
            }
        }

        private QuanLy.QuanLyLoaiBang quanLyLoaiBangControl = null;

        public QuanLy.QuanLyLoaiBang QuanLyLoaiBangControl {
            get {
                if (quanLyLoaiBangControl == null) {
                    quanLyLoaiBangControl = new QuanLy.QuanLyLoaiBang();
                } return quanLyLoaiBangControl;
            }
        }

        private QuanLy.QuanLyLoaiBao quanLyLoaiBaoControl = null;

        public QuanLy.QuanLyLoaiBao QuanLyLoaiBaoControl {
            get {
                if (quanLyLoaiBaoControl == null) {
                    quanLyLoaiBaoControl = new QuanLy.QuanLyLoaiBao();
                } return quanLyLoaiBaoControl;
            }
        }

        private QuanLy.QuanLyLoaiDiaOc quanLyLoaiDiaOcControl = null;

        public QuanLy.QuanLyLoaiDiaOc QuanLyLoaiDiaOcControl {
            get {
                if (quanLyLoaiDiaOcControl == null) {
                    quanLyLoaiDiaOcControl = new QuanLy.QuanLyLoaiDiaOc();
                } return quanLyLoaiDiaOcControl;
            }
        }

        private QuanLy.QuanLyQuyDinh quanLyQuyDinhControl = null;

        public QuanLy.QuanLyQuyDinh QuanLyQuyDinhControl {
            get {
                if (quanLyQuyDinhControl == null) {
                    quanLyQuyDinhControl = new QuanLy.QuanLyQuyDinh();
                } return quanLyQuyDinhControl;
            }
        }

        public ManHinhQuanLy() {
            InitializeComponent();

            // Insert code required on object creation below this point.

            App.ManHinhQuanLy = this;
        }

        private void btnQuanLyDangNhap_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(QuanLyDangNhapControl);
        }

        private void btnQuanLyDiaOc_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(QuanLyDiaOcControl);
        }

        private void btnQuanLyGia_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(QuanLyGiaControl);
        }

        private void btnQuanLyLoaiBang_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(QuanLyLoaiBangControl);
        }

        private void btnQuanLyLoaiBao_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(QuanLyLoaiBaoControl);
        }

        private void btnQuanLyLoaiDiaOc_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(QuanLyLoaiDiaOcControl);
        }

        private void Window_Loaded(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();         
            gridMain.Children.Add(QuanLyDangNhapControl);
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
            e.Cancel = true;
            this.Hide();
            gridMain.Children.Clear();
            quanLyDangNhapControl = null;
            quanLyDiaOcControl = null;
            quanLyLoaiBangControl = null;
            quanLyLoaiBaoControl = null;
            quanLyLoaiDiaOcControl = null;
            quanLyQuyDinhControl = null;           
            gridMain.Children.Add(QuanLyDangNhapControl);
        }

        private void btnBack_Click(object sender, RoutedEventArgs e) {
            if (MessageBoxResult.OK == MessageBox.Show("Có chắc chắn không?", "Cảnh báo", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel, MessageBoxOptions.None)) {
                this.Close();
            }
        }

        private void btnQuanLyQuyDinh_Click(object sender, RoutedEventArgs e) {
            gridMain.Children.Clear();
            gridMain.Children.Add(QuanLyQuyDinhControl);
        }
    }
}
